package com.ali.juejin.bind

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.request.RequestOptions

object BindImageView {
    @BindingAdapter("imageUrl")
    @JvmStatic
    fun loadImage(view: ImageView, url:String?){
        url.let {
            Glide.with(view.context).load(it).into(view)
        }

    }

    @BindingAdapter("imageCircleUrl")
    @JvmStatic
    fun loadCircleImage(view: ImageView, url:String?){
        url.let {
            Glide.with(view.context)
                .load(it)
                .apply(RequestOptions.bitmapTransform(CircleCrop()))
                .into(view)
        }

    }
}